package stu.aistar.day03;

/**
 * 买奶茶,每第二杯半价,单价是10元.求总价.
 */
public class CupDemo {
    public static void main(String[] args) {
        double price = 10d;//单价

        int cup = 5;//购买杯数

        double count = (cup/2)*price+(cup/2)*(price/2);

        //判断cup是否为奇数
        //if(cup % 2!=0)
        //total+=price;

        //偶数10 -> 1 0 1 0   -> 必然是0
        //奇数9 -> 1 0 0 1 -> 必然是1
        if((cup & 1) == 1)
            count+=price;

        System.out.println("总价:"+count+"元");


    }
}
